package com.zhangchenhui.mockitor;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("concurrenthashmapmisuse")
@Slf4j
public class ConcurrentHashMapMisuseController {
    @Autowired
    QueryDB queryDB;



    @GetMapping("wrong")
    public String wrong() throws InterruptedException {
        String data = queryDB.queryDb();
        if(data != null)
            return data;
        return "OK";
    }


    @GetMapping("wrong_2")
    public String wrong_2() {
        try{
            String data = queryDB.queryDbHa("1","2");
            if(data != null)
                return data;
            return "OK";
        }catch (Exception e){
            return "ERRPR";
        }

    }


}
